<?php

namespace App\Console\Commands;

use App\Models\Circle;
use Illuminate\Console\Command;

class CircleTop80Command extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'circle-top80';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        \Log::info('-----------start-circle-top80-----------------------------');
        $arr_id = Circle::orderBy('sort', 'desc')->limit(80)->pluck('id')->all();
        Circle::whereNotIn('id', $arr_id)->update(['is_top_80' => 0]);
        Circle::whereIn('id', $arr_id)->update(['is_top_80' => 1]);
        \Cache::forget('hot_search_user_key');
        \Log::info('-----------end-circle-top80------------------------------');
    }
}
